<div class = "main-view">
    <div class="left-margin top-margin"><strong class="am-text-primary am-text-lg">活动管理</strong></div>
    <form class="am-form-inline left-margin top-margin" role="form">
        <div class="am-form-group">
            <label>活动标题：</label> <input type="text" class="modal-input" style="height: 30px" ng-model="title" >
        </div>
        <div class="am-form-group">
            <label>开始时间：</label><input type="text" id="beginDate" style="height: 30px" data-date-format="yyyy-mm-dd" ng-model="beginDate">
            <label>结束时间：</label><input type="text" id="endDate" style="height: 30px" data-date-format="yyyy-mm-dd" ng-model="endDate">
        </div>
        <div class="am-form-group">
            <select data-am-selected="{btnSize: 'sm'}" ng-model="type" style="margin-left: 0px;">
                <option value=''>全部</option>
                <option value=0>普通</option>
                <option value=1>闪淘</option>
            </select>
        </div>

        <div class="am-modal am-modal-loading am-modal-no-btn" id="loading">
            <div class="am-modal-dialog">
                <div class="am-modal-hd">处理中...</div>
                <div class="am-modal-bd">
                    <span class="am-icon-spinner am-icon-spin"></span>
                </div>
            </div>
        </div>


        <button type="submit" class="am-btn am-btn-primary" ng-click="search($event)" data-target = "cascad-search">搜索</button>
    </form>
    <br>
    <div class="am-btn-group am-btn-group-xs left-margin top-margin">
        <button type="button" class="am-btn am-btn-default" data-am-modal="{target: '#doc-modal-add', width: 800, height: 600}"><span class="am-icon-plus"></span>添加活动</button>
        <button type="button" class="am-btn am-btn-default" ng-click="delete()"><span class="am-icon-trash-o"></span> 删除</button>
        <button type="button" class="am-btn am-btn-default" ng-click="export()"><span class="am-icon-download"></span> 导出</button>
    </div>
    <div id = "pagination" class = "pagination"></div>
    <div class="pagination-table left-margin" id="tab_activity" style = "margin-top: 0px;">
        <form class="am-form">
            <table class="am-table-striped am-table-hover table-main">
                <thead>
                <tr>
                    <th class="table-check"><input type="checkbox" ng-click="allSelected()"></th>
                    <!--<th>序号</th>-->
                    <th>标题</th>
                    <th>描述</th>
                    <th>类型</th>
                    <th>费用</th>
                    <th>活动说明</th>
                    <th>活动地址</th>
                    <th>开始时间</th>
                    <th>结束时间</th>
                    <th>报名用户/人数</th>
                    <th>URL</th>
                    <th>创建时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <tr ng-repeat="activity in activityList"  id = "{{activity.objId}}">
                    <td class="table-check"><input type="checkbox" class = "item-check"></td>
                    <!--<td>{{result.id}}</td>-->
                    <td>{{activity.title}}</td>
                    <td>{{activity.desc}}</td>
                    <td ng-show="activity.type==0">普通</td>
                    <td ng-show="activity.type==1">闪淘</td>
                    <td>{{activity.charge}}</td>
                    <td>{{activity.explain}}</td>
                    <td>{{activity.address}}</td>
                    <td>{{activity.beginDate|date:"yyyy-MM-dd hh:mm"}}</td>
                    <td>{{activity.endDate|date:"yyyy-MM-dd hh:mm"}}</td>
                    <!--<th><span ng-show="result.is_publish==0">否</span><span ng-show="result.is_publish==1">是</span></th>-->
                    <td>
                        <div class = "ell" style = "width: 70px;line-height: 1.2;"><a href="javascript:void(0)" id="resModal{{$index}}" ng-click="partakerShow(activity)">查看</a>/
                            {{activity.partakerCount}}
                        </div>
                    </td>
                    <td>{{activity.url}}</td>
                    <td><div>{{activity.dateCreated | date:'yyyy-MM-dd hh:mm:ss'}}</div></td>
                    <td>
                        <div class="am-btn-toolbar">
                            <div class="am-btn-group am-btn-group-xs">
                                <!--<button type="button" class="am-btn am-btn-default am-btn-xs am-hide-sm-only" ng-click="activityPreview(result)" >编辑</button>-->
                                <button type="button" class="am-btn am-btn-default am-btn-xs am-text-secondary" ng-click="activityEdit(activity)" >编辑</button>
                                <button type="button" class="am-btn am-btn-default am-btn-xs am-hide-sm-only" ng-click="activityPushShow(activity)" >推送</button>
                            </div>
                        </div>
                    </td>
                </tr>
                </tbody>
            </table>
        </form>
    </div>
    <div class = "left-margin">共<span id = 'page_number'>{{pageNumber}}</span>页 <span>{{count}}条数据</span></div>
    <!--新增框 -->
    <div class="am-modal am-modal-no-btn" tabindex="-1" id="doc-modal-add">
        <div class="am-modal-dialog">
            <div class="am-modal-hd border-bottom" style = "text-align: left;">新增活动
                <a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>&times;</a>
            </div>
            <div style="position:absolute; left:10%; right:10%;">
                <div class="am-modal-bd body-area text-left">
                    <form>
                    <br>
                    <label style="width:auto">活动标题：</label><input class="modal-input" style="width:518px;" ng-model="addData.title" required="required" tabindex="5">
                    <br>
                    <div>
                        <label style="width:auto">开始时间：</label><input type="text" class="modal-input" data-date-format="yyyy-mm-dd hh:ii" ng-model="addData.beginDate" id="beginDate_add">
                        <label style="width:auto">结束时间：</label><input type="text" class="modal-input" data-date-format="yyyy-mm-dd hh:ii" ng-model="addData.endDate" id="endDate_add">
                    </div>
                    <br>
                        <label  style="width:auto">活动类别：</label>
                        <select data-am-selected="{btnSize: 'sm'}" ng-model="addData.type" style="margin-left: 0px;">
                            <option value=0>普通</option>
                            <option value=1>闪淘</option>
                        </select>
                    <br>
                        <label style="width:82px">分享描述：</label>
                        <input type="text" class = "modal-input" style = "width: 600px;display: inline-block;" ng-model="addData.shareDesc">
                        <br>
                        <!--<div>-->
                            <!--<slide>-->
                                <!--<img ng-src="{{addData.shareImageURL}}" style="width: 100px;" onclick="if($(this).width()==100){-->
                                                    <!--$('img').width(100);-->
                                                    <!--$(this).width(360);-->
                                                    <!--}else{-->
                                                    <!--$(this).width(100);-->
                                                    <!--};">-->
                            <!--</slide>-->
                        <!--</div>-->
                        <br>
                        <div><label>分享图标</label>
                            <input type="file" id="images_upload_share" onchange="angular.element(this).scope().selectFile(this.files,'add','share')" accept="image/*">
                        </div>

                        <div id="image_share" class="image-result"></div>
                        <br>
                        <br>
                    <label style="width:auto">活动地址：</label><input class="modal-input" style="width:518px;" ng-model="addData.address" required="required">
                    <br>
                    <label>活动描述：</label><br/>
                    <textarea style="width:600px;height:150px;" ng-model="addData.desc" required tabindex="5"></textarea>
                    <br>
                    <div class="form-group">
                        <label class="control-label"  style="width:180px" for="textinput">图片(最多可上传6张):</label>
                        <input type="file" id="images_upload"
                               onchange="angular.element(this).scope().selectFile(this.files,'add')" multiple accept="image/*">
                        <div id="image_result" class="image-result"></div>
                    </div>
                    <br>
                    <label>活动说明：</label><br />
                    <textarea style="width:600px;height:150px;" ng-model="addData.explain" required tabindex="5"></textarea>
                    <br/><br/>
                    <label style="width:auto">费用：</label><input type="number" style="height:36px;" class = "modal-input" ng-model="addData.charge" required tabindex="5">
                    <br/>
                    <!--<label style="width:auto">URL：</label><br/>-->
                    <!--<input type="text" class = "modal-input" style = " ;width: 600px;display: inline-block;" ng-model="addData.url">-->
                    <!--<br/>-->

                </form>
                </div>
                <div class = "button-area border-top">
                    <button type="button" class="am-btn am-btn-success right-margin top-margin" ng-show="true" ng-click="add(addData,$event)" data-target = "cascad-search-add">保存</button>
                </div>
            </div>
        </div>
    </div>
    <!--编辑框 -->
    <div class="am-modal am-modal-no-btn" tabindex="-1" id="doc-modal-edit">
        <div class="am-modal-dialog">
            <div class="am-modal-hd border-bottom" style = "text-align: left;">编辑活动
                <a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>&times;</a>
            </div>
            <div style="position:absolute; left:10%; right:10%;">
                <div class="am-modal-bd body-area text-left">
                    <form>
                        <br>
                        <label style="width:82px">活动标题：</label><input class="modal-input" style="width:518px;" ng-model="updateData.title">
                        <br>
                        <div>
                            <label style="width:auto">开始时间：</label><input type="text" class="modal-input" data-date-format="yyyy-mm-dd hh:ii" ng-model="updateData.beginDate" id="beginDate_edit">
                            <label style="width:auto">结束时间：</label><input type="text" class="modal-input" data-date-format="yyyy-mm-dd hh:ii" ng-model="updateData.endDate" id="endDate_edit">

                            <!--<label style="width:auto">测试时间：</label><input type="text" value="2015-02-15 21:05" id="datetimepicker" class="am-form-field">-->
                        </div>
                        <br>
                        <label  style="width:auto">活动类别：</label>
                        <select data-am-selected="{btnSize: 'sm'}" ng-model="updateData.type" style="margin-left: 0px;">
                            <option value=0>普通</option>
                            <option value=1>闪淘</option>
                        </select>
                        <br>
                        <label style="width:82px">分享描述：</label>
                        <input type="text" class = "modal-input" style = "width: 600px;display: inline-block;" ng-model="updateData.shareDesc">
                        <br>
                        <div>
                            <slide>
                                <img ng-src="{{updateData.shareImage}}" style="width: 100px;" onclick="if($(this).width()==100){
                                                    $('img').width(100);
                                                    $(this).width(360);
                                                    }else{
                                                    $(this).width(100);
                                                    };">
                            </slide>
                        </div>
                        <br>
                        <div><label>分享图标</label>
                            <input type="file" id="images_upload_share_edit" onchange="angular.element(this).scope().selectFile(this.files,'edit','share')" accept="image/*">
                        </div>

                        <div id="image_share_edit" class="image-result"></div>
                        <br>
                        <label style="width:82px">活动地址：</label>
                        <!--<input type="text" class = "modal-input" style = "width:518px;" ng-model="updateData.address">-->
                        <input type="text" class = "modal-input" style = "width: 600px;display: inline-block;" ng-model="updateData.address">
                        <br>
                        <label>活动描述：</label><br />
                        <textarea style="width:600px;height:100px;" ng-model="updateData.desc" required tabindex="5"></textarea>
                        <br/>
                        <div>
                            <slide ng-repeat="img in updateData.images" active="img.active">
                                <img ng-src="{{img.imageURL}}" style="width: 100px;" onclick="if($(this).width()==100){
                                                    $('img').width(100);
                                                    $(this).width(360);
                                                    }else{
                                                    $(this).width(100);
                                                    };">
                            </slide>
                        </div>
                        <br>
                        <div class="form-group">
                            <label class="control-label"  style="width:180px" for="textinput">图片(最多可上传6张):</label>
                            <input type="file" id="images_upload_edit"
                                   onchange="angular.element(this).scope().selectFile(this.files,'edit')" multiple accept="image/*">
                            <div id="image_result_edit" class="image-result"></div>
                        </div>
                        <br/>
                        <label>活动说明：</label><br />
                        <textarea type="text" style="width:600px;height:100px;" ng-model="updateData.explain"></textarea>
                        <br/><br/>
                        <label style="width:auto;height:40px;">费用：</label><input style="height:36px;" type="number" class ="modal-input" ng-model="updateData.charge">
                        <br/>
                        <!--<label style="width:auto">URL：</label><br/>-->
                        <!--<input type="text" class = "modal-input" style = " ;width: 600px;display: inline-block;" ng-model="addData.url">-->
                        <!--<br/>-->

                    </form>
                </div>
                <div class = "button-area border-top">
                    <button type="button" class="am-btn am-btn-success right-margin top-margin" ng-show="true" ng-click="updateActivity(updateData)" data-target = "cascad-edit">保存</button>
                </div>
            </div>

        </div>
    </div>
    <!--参加活动用户-->
    <div class="am-modal am-modal-no-btn" tabindex="-1" id="doc-modal-partaker">
        <div class="am-modal-dialog">
            <div class="am-modal-hd border-bottom" style = "text-align: left">参加人员
                <a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>&times;</a>
            </div>
            <form class="am-form-inline left-margin top-margin" role="form" style="width: 750px">
                <!--<div class="am-form-group">-->
                    <!--<label>{{showData.title}}</label>-->
                <!--</div>-->
                <div id = "pagination_partaker" class = "pagination"></div>
                <div class="pagination-table left-margin" id="tab_partaker" style = "margin-top: 0px;">
                    <form class="am-form" style="width: 700px">
                        <table class="am-table-striped am-table-hover table-main">
                            <thead>
                                <tr>
                                    <th>用户昵称</th>
                                    <th>电话</th>
                                    <th>备注</th>
                                    <th>参加时间</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr ng-repeat="partaker in partakerList">
                                    <td>{{partaker.user.nickName}}</td>
                                    <td>{{partaker.phone}}</td>
                                    <td>{{partaker.desc}}</td>
                                    <td>{{partaker.dateCreated | date:'yyyy-MM-dd HH:mm:ss'}}</td>
                                </tr>

                            </tbody>


                        </table>
                    </form>

                </div>

            </form>

        </div>
    </div>
    <!--推送消息-->
    <div class="am-modal am-modal-no-btn" tabindex="-1" id="doc-modal-push">
        <div class="am-modal-dialog">
            <div class="am-modal-hd border-bottom" style = "text-align: left;">参加活动用户消息推送
                <a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>&times;</a>
            </div>
            <br>
            <div class="am-modal-bd body-area text-left">
                <form>
                    <label>消息内容：</label>
                    <textarea style="width:580px;height:150px;" ng-model="pushMsg"></textarea>
                </form>
            </div>
            <div class = "button-area border-top">
                <button type="button" class="am-btn am-btn-success right-margin top-margin" ng-show="true" ng-click="activityPushMsg(pushMsg)" data-target = "cascad-search-add">确认</button>
            </div>

        </div>
    </div>
    <!--loading-->
    <div class="am-modal am-modal-loading am-modal-no-btn" id="pushLoading">
        <div class="am-modal-dialog">
            <div class="am-modal-hd">正在推送...</div>
            <div class="am-modal-bd">
                <span class="am-icon-spinner am-icon-spin"></span>
            </div>
        </div>
    </div>

</div>

<script>

    Date.prototype.format = function (format) {
        var o = {
            "M+": this.getMonth() + 1, //month
            "d+": this.getDate(), //day
            "h+": this.getHours(), //hour
            "m+": this.getMinutes(), //minute
            "s+": this.getSeconds(), //second
            "q+": Math.floor((this.getMonth() + 3) / 3), //quarter
            "S": this.getMilliseconds() //millisecond
        }
        if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
                (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o) if (new RegExp("(" + k + ")").test(format))
            format = format.replace(RegExp.$1,
                    RegExp.$1.length == 1 ? o[k] :
                            ("00" + o[k]).substr(("" + o[k]).length));
        return format;
    }

    var fromDate = $('#beginDate').datepicker().on('changeDate', function (ev) {
        //alert(ev.date.format('yyyy-MM-dd'));
        //$scope.startDate=ev.date.format('yyyy-MM-dd');
        $("#beginDate").val(ev.date.format('yyyy-MM-dd'));
//        alert(ev.date);
    });

    var toDate = $('#endDate').datepicker().on('changeDate', function (ev) {
        // alert(ev.date.format('yyyy-MM-dd'));
        //$scope.endDate=ev.date.format('yyyy-MM-dd');
        $("#endDate").val(ev.date.format('yyyy-MM-dd'));
    });


    var fromDate_edit = $('#beginDate_edit').datetimepicker().on('changeDate', function (ev) {
        //alert(ev.date.format('yyyy-MM-dd'));
        //$scope.startDate=ev.date.format('yyyy-MM-dd');
//        $("#beginDate_edit").val(ev.date.format('yyyy-MM-dd hh:mm'));
//        alert(ev.date);
        $('#beginDate_edit').datetimepicker({
            format: 'yyyy-mm-dd hh:ii'
        });

    });

    var toDate_edit = $('#endDate_edit').datetimepicker().on('changeDate', function (ev) {
        $('#endDate_edit').datetimepicker({
            format: 'yyyy-mm-dd hh:ii'
        });
    });


    var fromDate_add = $('#beginDate_add').datetimepicker().on('changeDate', function (ev) {

        $('#beginDate_add').datetimepicker({
            format: 'yyyy-mm-dd hh:ii'
        });

    });

    var toDate_add = $('#endDate_add').datetimepicker().on('changeDate', function (ev) {
        $('#endDate_add').datetimepicker({
            format: 'yyyy-mm-dd hh:ii'
        });
    });


//
//    $('#beginDate_edit').datetimepicker({
//        format: 'yyyy-mm-dd hh:ii'
//    });
//
//    $('#endDate_edit').datetimepicker({
//        format: 'yyyy-mm-dd hh:ii'
//    });
</script>